﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 锁屏
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }
        private int hookInstance_OnKeyBoardDownEvent(KeyEventArgs e)
        {
            if (e.KeyCode == Keys.LWin || e.KeyCode == Keys.RWin || Control.ModifierKeys != Keys.None)
            {
                return 1;
            }
            return 0;
        }
        KeyBoardHook keyBoardHook;
        private void FormMain_Load(object sender, EventArgs e)
        {
            keyBoardHook = new KeyBoardHook();
            keyBoardHook.OnKeyBoardDownEvent += new KeyBoardHook.OnKeyDownHandel(hookInstance_OnKeyBoardDownEvent);
            // 开始侦听键盘
            keyBoardHook.Begin();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            keyBoardHook.Stop();
            this.Close();
        }
    }
}
